﻿using System;
using AnjLab.SyncIT.Core.Data.GoogleCode;
using NUnit.Framework;
using Converter = AnjLab.SyncIT.Core.Data.GoogleCode.GoogleTimeStringConverter;

namespace AnjLab.SyncIT.Core.Tests.Data.GoogleCode
{
    [TestFixture]
    public class TestGoogleTimeStringConverter
    {
        [Test]
        public void TestGoogleShortTimeStringToDateTime()
        {
            var now = new DateTime(2008, 3, 16, 12, 0, 0);

            //  March is earlier than september, so the september is at least in the past year
            Assert.AreEqual(0, new DateTime(2007, 9, 17, 12, 0, 0).CompareTo(
                                   GoogleTimeStringConverter.GoogleShortTimeStringToDateTime("Sep 17", now)));

            Assert.AreEqual(0, new DateTime(2008, 3, 16, 12, 0, 0).CompareTo(
                                   GoogleTimeStringConverter.GoogleShortTimeStringToDateTime("today", now)));

            Assert.AreEqual(0, new DateTime(2008, 3, 16, 12, 0, 0).CompareTo(
                                   GoogleTimeStringConverter.GoogleShortTimeStringToDateTime("moments ago", now)));

            Assert.AreEqual(0, new DateTime(2008, 3, 14, 12, 0, 0).CompareTo(
                                   GoogleTimeStringConverter.GoogleShortTimeStringToDateTime("2 days ago", now)));

            Assert.AreEqual(0, new DateTime(2008, 3, 16, 11, 25, 0).CompareTo(
                                   GoogleTimeStringConverter.GoogleShortTimeStringToDateTime("35 minutes ago", now)));
        }
    }
}